<?php

/**
 * User: @lixu
 * Date: 2019-05-28
 * Time: 11:10
 */

use Biz\service\wiki\ShopGoodsList as sShopGoodsList;
use Doraemon\tools\ActionLog;

class ShopGoodsListAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $shopId = $this->getRequest()->getQuery('shop_id', 0);
        if(!$shopId) {
            throw new \Exception("shop_id为空");
        }

        $page = $this->getRequest()->getQuery('page', 1);
        $page = $page < 1 ? 1 : abs($page);

        $sortType = $this->getRequest()->getQuery('sort_type', 0);

        $list = sShopGoodsList::getList($shopId, $page, $sortType, $this->uid);

        if($list['list'] && is_array($list['list'])){
            $list['list'] = \Doraemon\tools\StatSign::versionCompatible($list['list'], \Doraemon\tools\StatSign::WIKI_UP_GRADE_VERSION_522, \Doraemon\tools\BlockType::TYPE_WIKI, 'wiki' );
        }
        $this->setSuccess($list);

        ActionLog::log($this->uid, ['author_uid' => $shopId, 'sort_type' => $sortType, 'page' => $page], ActionLog::Biz_SHOP_GOODS_LIST);
    }
}